// /**
//  * Created by CK on 2016/10/17.
//  */
// var list;
// $(document).ready(function () {
//     list = $('#List');
//     $('.xh-datagrid-toolbar').parseToolbar(afterParseToolbar);
//     list.initDataGrid('getManageCommitData').setSelectThenEnable(['bt_list_del']);
//     $('#bt_list_del').click(function () {
//         var ids = list.getDataGridSelectedFields('iCommitId');
//         $.overtFun.clickDelList(ids, baseUrl + 'Log/delManageCommitData');
//     });
// });
// function afterParseToolbar()
// {
//     $.overtFun.vagueSearch(list);
// }
/**
 * create by gby 20180902
 */
$(function () {
    obj.init();
});

var obj = new function () {
    'use strict';
    return {
        dataGrid: null,
        params: {
            ids: null
        },
        init: function () {
            this.dataGrid = new xhDataGrid($('#List'), 'Log/getManageCommitData');
            this.dataGrid.parseToolbar().init();//.activeButton([], ['bt_list_del']);
            xhTool.bindDocKeyDown($('#bt_list_search'));
            this.listener();
        },
        listener: function () {
            var $this = this;
            xhTool.bindDocKeyDown(
                $('#bt_list_search').click(function (){
                    $this.dataGrid.reload({
                        submodule: xhExtra.getValue($('#list_submodule')),
                        operate: xhExtra.getValue($('#list_operate')),
                        explain: xhExtra.getValue($('#list_explain')),
                        content: xhExtra.getValue($('#list_content')),
                        startDate: xhExtra.getValue($('#list_startTime')),
                        endDate: xhExtra.getValue($('#list_endTime')),
                    })
                })
            );
        },
        funObj: function () {
            return {
                detail: function (msg) {
                    if (typeof(msg) != "undefined") {
                        window.top.xhTop.showModal({
                            title: '操作内容',
                            content: '<pre id="result" style="width:100%;height: 600px">\n' + obj.funObj().jsonFormat(msg) +'</pre>',
                            backClose: false,
                        });
                    } else {
                        window.top.xhTop.showMessage({title: '无操作内容'});
                        return false;
                    }
                },
                jsonFormat: function (json) {
                    if (typeof(json) != "undefined") {
                        if (typeof json != 'string') {
                            json = JSON.stringify(json, undefined, 2);
                        }
                        json = json.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
                        return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function(match) {
                            var cls = 'number';
                            var color = 'black';
                            if (/^"/.test(match)) {
                                if (/:$/.test(match)) {
                                    cls = 'key';
                                    color = 'res';
                                } else {
                                    cls = 'string';
                                    color = 'green';
                                }
                            } else if (/true|false/.test(match)) {
                                cls = 'boolean';
                                color = 'blue';
                            } else if (/null/.test(match)) {
                                cls = 'null';
                                color = 'magenta';
                            }
                            return '<span class="' + cls + '" style="color:' + color + ';white-space:pre-wrap">' + match + '</span>';
                        });
                    } else {
                        return '<span style="white-space:pre-wrap">无</span>';
                    }

                }
            }
        }
    }
};